<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * Shop filter form base class.
 *
 * @package    filters
 * @subpackage Shop *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseShopFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'user_id'            => new sfWidgetFormDoctrineChoice(array('model' => 'User', 'add_empty' => true)),
      'province_id'        => new sfWidgetFormDoctrineChoice(array('model' => 'Province', 'add_empty' => true)),
      'amphur_id'          => new sfWidgetFormDoctrineChoice(array('model' => 'Amphur', 'add_empty' => true)),
      'restaurant_type_id' => new sfWidgetFormDoctrineChoice(array('model' => 'RestaurantType', 'add_empty' => true)),
      'felling_id'         => new sfWidgetFormDoctrineChoice(array('model' => 'Felling', 'add_empty' => true)),
      'status'             => new sfWidgetFormFilterInput(),
      'shop_name'          => new sfWidgetFormFilterInput(),
      'open_time'          => new sfWidgetFormFilterInput(),
      'close_time'         => new sfWidgetFormFilterInput(),
      'location_detail'    => new sfWidgetFormFilterInput(),
      'location_map_x'     => new sfWidgetFormFilterInput(),
      'location_map_y'     => new sfWidgetFormFilterInput(),
      'location_map_z'     => new sfWidgetFormFilterInput(),
      'carpark'            => new sfWidgetFormFilterInput(),
      'promotion'          => new sfWidgetFormFilterInput(),
      'point_total'        => new sfWidgetFormFilterInput(),
      'point_count'        => new sfWidgetFormFilterInput(),
      'point_avg'          => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'user_id'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'User', 'column' => 'user_id')),
      'province_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Province', 'column' => 'province_id')),
      'amphur_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Amphur', 'column' => 'amphur_id')),
      'restaurant_type_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'RestaurantType', 'column' => 'restaurant_type_id')),
      'felling_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Felling', 'column' => 'felling_id')),
      'status'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'shop_name'          => new sfValidatorPass(array('required' => false)),
      'open_time'          => new sfValidatorPass(array('required' => false)),
      'close_time'         => new sfValidatorPass(array('required' => false)),
      'location_detail'    => new sfValidatorPass(array('required' => false)),
      'location_map_x'     => new sfValidatorPass(array('required' => false)),
      'location_map_y'     => new sfValidatorPass(array('required' => false)),
      'location_map_z'     => new sfValidatorPass(array('required' => false)),
      'carpark'            => new sfValidatorPass(array('required' => false)),
      'promotion'          => new sfValidatorPass(array('required' => false)),
      'point_total'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'point_count'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'point_avg'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('shop_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Shop';
  }

  public function getFields()
  {
    return array(
      'shop_id'            => 'Number',
      'user_id'            => 'ForeignKey',
      'province_id'        => 'ForeignKey',
      'amphur_id'          => 'ForeignKey',
      'restaurant_type_id' => 'ForeignKey',
      'felling_id'         => 'ForeignKey',
      'status'             => 'Number',
      'shop_name'          => 'Text',
      'open_time'          => 'Text',
      'close_time'         => 'Text',
      'location_detail'    => 'Text',
      'location_map_x'     => 'Text',
      'location_map_y'     => 'Text',
      'location_map_z'     => 'Text',
      'carpark'            => 'Text',
      'promotion'          => 'Text',
      'point_total'        => 'Number',
      'point_count'        => 'Number',
      'point_avg'          => 'Number',
    );
  }
}